package cn.fu.security.base64;

import org.apache.commons.codec.binary.Base64;

/**
 * @Title: Base64.java
 * @Package cn.fu.security.base64
 * @Description: Base64算法（严格地说，属于编码格式，而非加密算法）
 * 应用：e-mail,密钥，证书
 * 产生：邮件只传输acki码
 * @author zhangxiaofu
 * @Company www.viewhigh.com
 * @date 2016年8月20日 下午11:16:21
 * @version V1.0
 */
public class MyBase64 {

	private static String src = "99fu";

	public static void main(String[] args) {
		commonsCodesBasy64();
		bouncyCastleBase64();
	}

	// bc
	public static void bouncyCastleBase64() {
		byte[] encode = org.bouncycastle.util.encoders.Base64.encode(src.getBytes());
		System.err.println("encode:" + new String(encode));

		byte[] decode = org.bouncycastle.util.encoders.Base64.decode(encode);
		System.err.println("decode:" + new String(decode));
	}

	// cc
	public static void commonsCodesBasy64() {
		byte[] encodeBase64 = Base64.encodeBase64(src.getBytes());
		System.err.println("encode:" + new String(encodeBase64));

		byte[] decodeBase64 = Base64.decodeBase64(encodeBase64);
		System.err.println("decode:" + new String(decodeBase64));
	}
}
